<template>
  <div id="app">
    <business-header :header="headerInfos" />
    <table-control :tab-title="tabTitle" @itemClick="itemClick" />
    <router-view/>
  </div>
</template>
<script>


  import {getdata} from "./network/request";
  import BusinessHeader from "./views/Business/Children/BusinessHeader";
  import tableControl from "./views/Business/Children/tableControl";

  export default {
    name:'app',
    components:{
      BusinessHeader,
      tableControl
    },
    data(){
      return {
        headerInfos:{},
        tabTitle: ["商品","评论","商家"],
        path:['/goods','/comment','/store'],
        ouccerrindex:0,
        goodslist:[],
      }
    },
    methods:{
      itemClick(index){
        this.ouccerrindex=index
        this.$router.push(this.path[this.ouccerrindex])
      }
    },

    created() {
      getdata().then(
          res=>{
            //商家头部信息
            this.headerInfos.name=res.data.seller.name;//"粥品香坊（回龙观）"
            this.headerInfos.descripte=res.data.seller.description;//蜂鸟快送
            this.headerInfos.avatar=res.data.seller.avatar;//店铺头像
            this.headerInfos.description=res.data.seller.supports[0].description;//"在线支付满28减5"
            this.headerInfos.bulletin=res.data.seller.bulletin;//简介
            this.headerInfos.deliveryTime=res.data.seller.deliveryTime;//配送时间

            //商品信息
            this.goodslist=res.data.goods;

            console.log(res.data.goods);
          }
      )
      //刷新的时候同步更新view视图
      this.$router.push(this.path[this.ouccerrindex])

    },
    updated() {
      console.log(this.$route.name);
    }

  }
</script>
<style>
  body{
    margin:0;
    padding: 0;
  }

</style>
